#include <iostream>
#include "lapack.h"

using namespace std;

int main(int argc, char ** argv){
  int m, n, nrhs, lda, ldb, rank, LWORK, info;
  double rcond;
  double *A, *B, *S, *WORK;
  m = 3;
  n = 2;
  nrhs = 1;
  A = new double[m*n];
  B = new double[m*nrhs];
  S = new double[m];
  lda = m;
  ldb = m;
  rcond = 1e-6;
  LWORK = 5*m;
  WORK = new double[LWORK];
  A[0] = 2.0;
  A[1] = 0.0;
  A[2] = 0.0;
  A[3] = 0.0;
  A[4] = 0.0;
  A[5] = 0.0;
  B[0] = 1.0;
  B[1] = 1.0;
  B[2] = 1.0;
  dgelss_(&m, &n, &nrhs, A, &lda, B, &ldb, S, &rcond, &rank, WORK, &LWORK,\
	  &info);
  cout << "B[0] = " << B[0] << endl;
  cout << "B[1] = " << B[1] << endl;
  cout << "B[2] = " << B[1] << endl;
  delete []A;
  delete []B;
  delete []S;
  delete []WORK;
  return 1;
}
